package cn.monkey.family.server.domain.uc.auth.wechat;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestClient;

@Configuration
public class WechatConfig {

    @Bean
    @ConfigurationProperties(prefix = "auth.wechat")
    WechatProperties wechatProperties() {
        return new WechatProperties();
    }

    @Bean
    WechatClient wechatClient(RestClient restClient,
                              WechatProperties wechatProperties,
                              WechatUserRepository wechatUserRepository) {
        return new RemoteWechatClient(restClient, wechatProperties, wechatUserRepository);
    }
}
